const express = require('express');
const router = express.Router();
const pool = require('../pool.js');
const mysql = require('mysql');

router.get('/',function(req,res,next){
	// pool.getConnection(function(err,connection){
	// 	if(err){
	// 		throw err;
	// 	}

		const querySQL = `SELECT * FROM userOrder`;
		// connection.query(querySQL,function(error,results,fields){
		// 	if(error){
		// 		throw error;
		// 	}
		// 	console.log(results);
		// 	console.log(fields);
        //  connection.release();

		// });

    var connection = mysql.createConnection({
        host: '127.0.0.1',
        user: 'root',
        password: 'root',
        database: 'wechat_user',
        port: '3306',
    });

    connection.connect(function(err){
        if(err){
            console.log(err.stack);
            return;
        }

        console.log(connection.threadId);
    });

    connection.query(querySQL,function(error,results,fields){
        if(error){
            throw error;
        }

        // console.log(results);
        // console.log(fields);
        // res.json({results,fields});
        // connection.release();

    });

    connection.end();
    // process.send({key:'hello world'});
    res.render('index2');
});
    // res.render('index',{title:'hello world'});

module.exports = router;